using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Xunit;

namespace Cooking.UnitTest.Helpers
{
    public static class UnitTestHelpers
    {
        public static void ShouldContain<T>(this ICollection<T> list, Expression<Func<T, bool>> expression)
        {
            T item = list.FirstOrDefault(expression.Compile());
            Assert.False(Equals(item, default(T)));
        }

        public static void ShouldContain<T>(this ICollection<T> lst, T item)
        {
            Assert.True(lst.Contains(item));
        }

        public static void ShouldNotContain<T>(this ICollection<T> list, Expression<Func<T, bool>> expression)
        {
            T item = list.FirstOrDefault(expression.Compile());
            Assert.True(Equals(item, default(T)));
        }

        public static void ShouldNotContain<T>(this ICollection<T> lst, T item)
        {
            Assert.False(lst.Contains(item));
        }

        public static void ShouldBeEmpty(this string value)
        {
            Assert.True(value == string.Empty);
        }

        public static void ShouldBeEmpty<T>(this ICollection<T> list)
        {
            Assert.True(list.Count == 0);
        }

        public static void ShouldNotBeEmpty(this string value)
        {
            Assert.True(value != string.Empty);
        }

        public static void ShouldBeEqualTo(this string value, string shouldEqual)
        {
            Assert.Equal(shouldEqual, value);
        }

        public static void ShouldBeEqualTo(this object item, object shouldEqual)
        {
            Assert.Equal(shouldEqual, item);
        }

        public static void ShouldBeTrue(this bool condition)
        {
            Assert.True(condition);
        }

        public static void ShouldBeFalse(this bool condition)
        {
            Assert.False(condition);
        }
    }
 
}